package main

import (
	"flag"
	"log"
	"net"

	"github.com/gin-gonic/gin"

	"lux/internal/logger"
	"lux/pkg/config"
)

var configPath = flag.String("conf", "lux.yaml", "configuration path, and only support yaml")

func main() {
	// init config
	flag.Parse()
	if err := config.InitConfiguration(*configPath); err != nil {
		log.Fatalln(err)
		return
	}

	// init logger
	logger.InitLogger()

	// set router
	r := gin.Default()

	// start server
	host := config.CONF.GetString("server.host")
	port := config.CONF.GetString("server.port")
	addr := net.JoinHostPort(host, port)
	r.Run(addr)
}
